<!--
 * @Author: 严晗 823841034@qq.com
 * @Date: 2023-10-19 10:37:13
 * @LastEditors: 严晗 823841034@qq.com
 * @LastEditTime: 2024-03-02 14:33:16
 * @FilePath: /yike-admin/Users/yanhan/vite-project/src/pages/sales/daily/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- 日报 -->
<template>
	<div>
		<search-form :searchOptions="searchOptions" @search="handleSearch" />

		<table-pagin ref="tablePaginRef" :loading="loading" indexMethod :tableLeft="tableLeftBtnOptions" :tableHeader="tableOptions" :table-data="tableData" :page="page" :sizeChange="handleSizeChange" :currentChange="handleCurrentChange">
			<template #tableLeft>
				<span v-for="(item, index) in tableLeftBtnOptions" :key="index" class="mr-2">
					<el-button :type="item.type" size="small" :icon="item.icon" @click="handleBtnClick(index)" :loading="currentBtnLoading === index">{{item.label}}</el-button>
				</span>
			</template>
		</table-pagin>
	</div>
</template>
<script setup>
import { onMounted } from 'vue'
import SearchForm from '~/components/SearchForm.vue'
import TablePagin from '~/components/TablePagin.vue'
import { useSearchOptions, useTableOptions, useTableData, usePage, useSearch, useTableBtnOptions, useExportExcel } from '~/crud/sale/useDay'


// 搜索配置项
const { searchOptions } = useSearchOptions()

// 表格配置项
const { tableOptions, tableTempOptions } = useTableOptions()

// 分页数据
const { page, handleSizeChange, handleCurrentChange } = usePage()

// 搜索数据
const { searchForm, refreshSearchFlag, handleSearch } = useSearch()

// 表格数据
const { loading, tableData, tablePaginRef, getList } = useTableData(page, searchForm, refreshSearchFlag, tableOptions, tableTempOptions)

// 左侧按钮配置项
const { tableLeftBtnOptions, currentBtnLoading, handleBtnClick } = useTableBtnOptions(searchForm, useExportExcel)

onMounted(() => {
	getList()
})
</script>
